package com.qlk.odcinterface.service.impl;

import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.qlk.odcinterface.domain.PmsFullCutChannel;
import com.qlk.odcinterface.domain.query.PmsFullCutChannelQuery;
import com.qlk.odcinterface.manager.PmsFullCutChannelManager;
import com.qlk.odcinterface.service.PmsFullCutChannelService;
import com.qlk.odcinterface.utils.exceptions.ExistedException;
import com.qlk.common.utils.page.PageUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.perf4j.aop.Profiled;
 
/**
 * PmsFullCutChannelService接口的实现类
 * 
 * @author zhaoyanan
 * @version 2016-4-14 13:22:58
 * 
 */
@Service
public class PmsFullCutChannelServiceImpl implements PmsFullCutChannelService {

    /** LOG */
    private static final Log LOG = LogFactory.getLog(PmsFullCutChannelServiceImpl.class);

    @Autowired
    private PmsFullCutChannelManager pmsFullCutChannelManager;

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutChannelService.batchInsert")
    public boolean insert(List<PmsFullCutChannel> pmsFullCutChannelList) {
        boolean resultFlag = false;
        try {
            if (CollectionUtils.isNotEmpty(pmsFullCutChannelList)) {
                resultFlag = pmsFullCutChannelManager.insert(pmsFullCutChannelList);
            } else {
                LOG.warn("PmsFullCutChannelServiceImpl#batchInsert failed, param is illegal.");
            }
        } catch (Exception e) {
            LOG.error("PmsFullCutChannelServiceImpl#batchInsert has error.", e);
        }
        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutChannelService.insert")
    public boolean insert(PmsFullCutChannel pmsFullCutChannel) {
        boolean resultFlag = false;
        try {
            if (null != pmsFullCutChannel) {
                if (pmsFullCutChannelManager.exist(pmsFullCutChannel)) {
                    throw new ExistedException();
                }
                resultFlag = pmsFullCutChannelManager.insert(pmsFullCutChannel);
            } else {
                LOG.warn("PmsFullCutChannelServiceImpl#insert failed, param is illegal.");
            }
        } catch (ExistedException e) {
            LOG.warn("PmsFullCutChannelServiceImpl#insert failed, pmsFullCutChannel has existed.");
            throw e;
        } catch (Exception e) {
            LOG.error("PmsFullCutChannelServiceImpl#insert has error.", e);
        }
        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutChannelService.update")
    public boolean update(PmsFullCutChannel pmsFullCutChannel) {
        boolean resultFlag = false;
        try {
            if (null != pmsFullCutChannel && null != pmsFullCutChannel.getId()) {
                resultFlag = pmsFullCutChannelManager.update(pmsFullCutChannel);
            } else {
                LOG.warn("PmsFullCutChannelServiceImpl#update failed, param is illegal.");
            }
        } catch (Exception e) {
            LOG.error("PmsFullCutChannelServiceImpl#update has error.", e);
        }
        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutChannelService.queryPmsFullCutChannelList")
    public List<PmsFullCutChannel> queryPmsFullCutChannelList(PmsFullCutChannelQuery queryBean) {
        List<PmsFullCutChannel> pmsFullCutChannelList = null;
        try {
            pmsFullCutChannelList = pmsFullCutChannelManager.queryPmsFullCutChannelList(queryBean);
        } catch (Exception e) {
            LOG.error("PmsFullCutChannelServiceImpl#queryPmsFullCutChannelList has error.", e);
        }
        return pmsFullCutChannelList;
    }

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutChannelService.queryPmsFullCutChannelListWithPage")
    public List<PmsFullCutChannel> queryPmsFullCutChannelListWithPage(PmsFullCutChannelQuery queryBean, PageUtil pageUtil) {
        List<PmsFullCutChannel> pmsFullCutChannelList = null;
        try {
            pmsFullCutChannelList = pmsFullCutChannelManager.queryPmsFullCutChannelListWithPage(queryBean, pageUtil);
        } catch (Exception e) {
            LOG.error("PmsFullCutChannelServiceImpl#queryPmsFullCutChannelListWithPage has error.", e);
        }
        return pmsFullCutChannelList;
    }

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutChannelService.delete")
    public boolean delete(PmsFullCutChannel pmsFullCutChannel) {
        boolean resultFlag = false;
        try {
            if (null != pmsFullCutChannel && null != pmsFullCutChannel.getId()) {
                resultFlag = pmsFullCutChannelManager.delete(pmsFullCutChannel);
            } else {
                LOG.warn("PmsFullCutChannelServiceImpl#delete param is illegal.");
            }
        } catch (Exception e) {
            LOG.error("PmsFullCutChannelServiceImpl#delete has error.", e);
        }
        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutChannelService.batchDelete")
    public boolean delete(PmsFullCutChannel[] pmsFullCutChannels) {
        boolean resultFlag = false;
        try {
            if (null != pmsFullCutChannels && pmsFullCutChannels.length > 0) {
                resultFlag = pmsFullCutChannelManager.delete(pmsFullCutChannels);
            } else {
                LOG.warn("PmsFullCutChannelServiceImpl#batchDelete failed, param is illegal.");
            }
        } catch (Exception e) {
            LOG.error("PmsFullCutChannelServiceImpl#batchDelete has error.", e);
        }
        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutChannelService.getPmsFullCutChannelById")
    public PmsFullCutChannel getPmsFullCutChannelById(Integer id) {
        PmsFullCutChannel pmsFullCutChannel = null;
        try {
            if (null != id) {
                pmsFullCutChannel = pmsFullCutChannelManager.getPmsFullCutChannelById(id);
            } else {
                LOG.warn("PmsFullCutChannelServiceImpl#getPmsFullCutChannelById failed, param is illegal.");
            }
        } catch (Exception e) {
            LOG.error("PmsFullCutChannelServiceImpl#getPmsFullCutChannelById has error.", e);
        }
        return pmsFullCutChannel;
    }
}

